import { resolve } from 'path'
import { defineConfig, externalizeDepsPlugin, bytecodePlugin } from 'electron-vite'
import vue from '@vitejs/plugin-vue';
// import { babel } from '@rollup/plugin-babel';
// import commonjs from 'vite-plugin-commonjs';




export default defineConfig({
  main: {
    plugins: [externalizeDepsPlugin(), bytecodePlugin()]
  },
  preload: {
    plugins: [externalizeDepsPlugin(), bytecodePlugin()]
  },
  renderer: {
    build: {
      // outDir: resolve(__dirname, 'dist/renderer'), // 打包后输出目录
      rollupOptions: {
        input: {
          main: resolve(__dirname, 'src/renderer/index.html'),
          child: resolve(__dirname, 'src/renderer/src/mini_program/index.html')
        },
      },
      commonjsOptions: {
        transformMixedEsModules: true
      }
    },
    resolve: {
      alias: {
        '@renderer': resolve('src/renderer/src'),
      },
    },
    server: {
      hmr: true, // 启用 HMR
      /* hmr: {
        overlay: false, // 可选：关闭错误覆盖层
      }, */
    },
    plugins: [
      // commonjs(),
      vue(),

    ]
  },
})
